<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.livequery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.extend.js"></script>

<div class="module">
   <p class="title">修改密码</p>
   
   <form id="form">
   		<div class="content">
       	   <br><br>
           <ul class="summary-table" style="width: 30%;margin: auto auto">
               
               <li class="colx">
                   <label class="col1">原密码</label>
                   <span class="col2">
                       <input class="ctr-input" id="oldpwd" name="oldpwd" data-vdt="required" type="password"/>
                   </span>
               </li>
               
               <li class="colx">
                   <label class="col1">新密码</label>
                   <span class="col2">
                       <input class="ctr-input" id="password" name="password" data-vdt="required rangelength 6 20 #字符长度范围[6-20]" type="password"/>
                   </span>
               </li>
               
               <li class="colx">
                   <label class="col1">确认新密码</label>
                   <span class="col2">
                       <input class="ctr-input" id="repassword" name="repassword" data-vdt="required rangelength 6 20 #字符长度范围[6-20] equalTo [id=password]" type="password"/>
                   </span>
               </li>
               
              
           </ul>

           <div class="form-button-group" style="margin: auto auto">
               <span class="form-button saveBtn" id="updateSubmit">保存</span>
            </div>
        
    	</div>
    </form>
</div>
<script type="text/javascript">
	$('#updateSubmit').bind('click', function(){
		if($("#form").valid()){
			$.ajax({
	            type: "POST",
	            url: contextPath + "/web/settings/updatePwd",
	            data: {'oldpwd': $("#oldpwd").val(), 'password': $("#password").val()},
	            dataType : "json",
	            beforeSend : function(){
	            	$("#beforeLoading").show();
	            },
	            success: function (res) {
	            	$("#beforeLoading").hide();
	            	if(res.resData.status){
	            		
	            		succHint("修改密码成功，请重新登录.");
	            		
	            		setTimeout(function(){
                			window.location.href = contextPath + "/view/exit";
                		}, 2500);
	            		
	            	}
	            	else{
	            		failHint(res.msg);
	            	}
	            	
	            },
	            error: function (msg) {
	            	failHint();
	            }
	        });
		}
		
	});
</script>

